package Redis;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.exceptions.JedisConnectionException;

public class Redis {
 /*   //Redis 地址
    private String url = "127.0.0.1";
    //Redis 端口号
    private int port = 6379;
    //可连接的最大数目 默认为8 -1 为不限制
    private int MAX_ACTIVE = 1024;
    // 控制一个pool有多少个状态为空闲，默认为8
    private int MAX_IDLE = 1024;
    //等待连可用的最大时间,默认为-1 为永不超时
    // 如果超时抛出JedisConnectionException异常
    private int MAX_WAIT = 10000;
    private int TIMEOUT = 10000;
    //在borrow一个jedis实例时,是否提前进行validate操作,如果为true,则得到的实例均是可用的
    private static boolean TEST_NO_BORROW = true;
    private static JedisPool jedisPool = null;

    public Redis() throws JedisConnectionException {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(MAX_IDLE);
        config.setMaxWait(10000);
        config.setTestOnBorrow(TEST_NO_BORROW);
        jedisPool = new JedisPool(config, url, port);
    }

    *//**
     * 获取Jedis实例
     *//*
    public Jedis getJedis() throws JedisConnectionException{
        return jedisPool.getResource();
    }*/
}